import React from "react";
import { message } from "antd";
import Warn from "@/media/model/warn.png";
import Info from "@/media/model/info.png";
import Success from "@/media/model/success.png";
import ErrorIcon from "@/media/model/error.png";
const showToast = (type = "default", content, opts = {}) => {
  const theme = localStorage?.getItem("theme") || "default";
  const options = {
    duration: 3,
    theme: theme === "default" ? "dark" : "light",
    ...opts,
  };
  switch (type) {
    case "success":
      message.success({
        content: content,
        icon: (
          <img
            src={Success}
            alt="Success"
            className="w-[16px] h-[16px] mr-[8px]"
          />
        ),
        ...options,
      });
      break;
    case "error":
      message.error({
        content: content,
        icon: (
          <img
            src={ErrorIcon}
            alt="ErrorIcon"
            className="w-[16px] h-[16px] mr-[8px]"
          />
        ),
        ...options,
      });
      break;
    case "info":
      message.info({
        content: content,
        icon: (
          <img src={Info} alt="Info" className="w-[16px] h-[16px] mr-[8px]" />
        ),
        ...options,
      });
      break;
    case "warning":
      message.warning({
        content: content,
        icon: (
          <img src={Warn} alt="Warn" className="w-[16px] h-[16px] mr-[8px]" />
        ),
        ...options,
      });
      break;
    default:
      message.info({
        content: content,
        icon: (
          <img src={Info} alt="Info" className="w-[16px] h-[16px] mr-[8px]" />
        ),
        ...options,
      });
  }
};

export default showToast;
